package com.cherrypt.api.core.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cherrypt.api.model.dataobject.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

/**
 * @author intent
 * @date 2019/7/14 16:02
 * @about <link href='http://zzyitj.xyz/'/>
 */
public interface UserInfoDao extends BaseMapper<UserInfo> {
    @Insert(value = "INSERT INTO t_user_info (uid, passkey, username, sex, uploaded, ip, created, modify) VALUES (#{uid}, #{passkey}, #{username}, #{sex}, #{uploaded}, INET6_ATON(#{ip}), #{created}, #{modify})")
    int insertUserInfo(UserInfo userInfo);

    @Select(value = "SELECT id, uid, passkey, username, sex, uploaded, downloaded, diamond, gold, exp, inviter_id, avatar_url, created, modify, INET6_NTOA(ip) as ip, status FROM t_user_info WHERE uid = #{uid}")
    UserInfo selectUserInfoByUid(int uid);

    @Select(value = "SELECT id, uid, username, sex, uploaded, downloaded, diamond, gold, exp, inviter_id, avatar_url, created, modify, status FROM t_user_info WHERE uid = #{uid}")
    UserInfo selectFriendById(int uid);
}
